package v1alpha1

import (
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type LogStatus string

const (
	SuccessStatus LogStatus = "Success"
	FailedStatus  LogStatus = "Failed"
)

type Phase string

const (
	Pending Phase = "Pending"
	Running Phase = "Running"
	Waiting Phase = "Waiting"
	Failed  Phase = "Failed"
	Unknown Phase = "Unknown"
)

type ConditionType string

const (
	UpdateConfigMap         ConditionType = "UpdateConfigMap"
	CheckAnnotationAndLabel ConditionType = "CheckAnnotationAndLabel"
	CorrectnessOfConfigs    ConditionType = "CorrectnessOfConfigs"
	LastHandledHash         ConditionType = "LastHandledHash"
)

type ConditionStatus string

const (
	ConditionTrue    ConditionStatus = "True"
	ConditionFalse   ConditionStatus = "False"
	ConditionUnknown ConditionStatus = "Unknown"
)

type Condition struct {
	Type               ConditionType   `json:"type" protobuf:"bytes,1,opt,name=type,casttype=ConditionType"`
	Status             ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"`
	LastTransitionTime metav1.Time     `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"`
	Message            string          `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"`
}

type SearchStatus string

const (
	Found    SearchStatus = "Found"
	NotFound SearchStatus = "Not Found"
)

type Annotation struct {
	Name           string   `json:"name,omitempty" protobuf:"bytes,1,opt,name=type"`
	Containers     []string `json:"containers,omitempty"`
	InitContainers []string `json:"initContainers,omitempty"`
}

type Label struct {
	Name           []string `json:"name,omitempty" protobuf:"bytes,1,opt,name=type"`
	Containers     []string `json:"containers,omitempty"`
	InitContainers []string `json:"initContainers,omitempty"`
}

type ContainerInfo struct {
	Name   string       `json:"name" protobuf:"bytes,1,opt,name=type"`
	Status SearchStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=SearchStatus"`
}

type LabelAndAnnotationNotFound struct {
	Containers     []string `json:"containers,omitempty"`
	InitContainers []string `json:"initContainers,omitempty"`
}

type LabelAndAnnotationInfo struct {
	LabelAndAnnotationNotFound LabelAndAnnotationNotFound `json:"labelAndAnnotationNotFound,omitempty"`
	Annotations                []Annotation               `json:"annotations,omitempty"`
	Labels                     []Label                    `json:"labels,omitempty"`
}

// +kubebuilder:pruning:PreserveUnknownFields
type ResourceStatus struct {
	Name       string `json:"name,omitempty"`
	Kind       string `json:"kind,omitempty"`
	ApiVersion string `json:"apiVersion,omitempty"`
	Message    string `json:"message,omitempty"`
	Phase      string `json:"phase,omitempty"`
	Status     string `json:"status,omitempty"`
}

// +kubebuilder:object:generate=false
type Namespaced interface {
	GetNamespacedName() string
}
